﻿@using ABC.Controllers.ViewModels
@using ABC.Controllers.ViewModels.My
@model MyObjectsViewModel
@{
    ViewBag.Title = "Объекты страхования - Азбука24";
    Layout = "~/Views/Shared/_MyLayout.cshtml";
    var query = Request.Params["query"];
    var status = Request.Params["status"];
    var pagesize = Request.Params["pagesize"];
}
<script>
    function Filter() {
        location.href = '@Url.Action("Objects", "Clients")?' + ($("#Query").val() ? "query=" + $("#Query").val() : "") + ($("#Status").val() == "atwork" ? "" : "&status=" + $("#Status").val()) +
            ($("#PageSize").val() == '@Model.ListForPageSize.First().Value' ? "" : "&pagesize=" + $("#PageSize").val());
    }
</script>
<div class="row-fluid">
    <!--// Левая колонка -->
    @{Html.RenderPartial("_SectionClientsMenu", new BaseViewModel());}
    <!--// Правая колонка -->
    <div class="span9">
        <div class="page-header">
            <h2>
                Объекты страхования</h2>
        </div>
        <div class="row-fluid">
            <div class="span3">
                <div class="control-group">
                    <label class="control-label" for="Query">
                        Поиск</label>
                    <div class="controls">
                        @Html.TextBoxFor(x => x.Query, new { @class = "search-query input-medium", placeholder = "Данные клиента" })
                    </div>
                </div>
            </div>
            <div class="span3">
                <div class="control-group">
                    <label class="control-label" for="Status">
                        Статус</label>
                    <div class="controls">
                        @Html.DropDownListFor(x => x.Status, Model.ListForStatus, new { @class = "input-medium" })
                    </div>
                </div>
            </div>
            <div class="span3">
            </div>
            <div class="span3">
                <div class="control-group">
                    <label class="control-label" for="phone-01">
                        Фильтр</label>
                    <div class="controls">
                        <div class="btn-group">
                            <button type="button" class="btn" onclick="Filter();">
                                Применить</button>
                            <button class="btn" rel="tooltip" data-original-title="Сбросить фильтр" onclick="location.href='@Url.Action("Objects")'">
                                <i class="icon-refresh"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <table class="table table-bordered table-striped" id="objects">
            <thead>
                <tr>
                    <th class="col-1">
                        <input type="checkbox" id="inlineCheckbox01" onchange="ChangeAllCheck();" value="option0"
                            title="Выделить все">
                    </th>
                    <th>
                        Объект страхования
                    </th>
                    <th>
                        Страхователь
                    </th>
                    <th>
                        Продукт страхования
                    </th>
                </tr>
            </thead>
            <tbody>
                @using (Html.BeginForm("DeleteObjects", "Clients", FormMethod.Post, new { id = "form1" }))
                {
                    @Html.Hidden("query")
                    @Html.Hidden("status")
                    @Html.Hidden("pagesize")
                    @Html.Hidden("page", Model.PageNumber)
                    foreach (var obj in Model.Objects)
                    {
                    <tr>
                        <td class="col-1">
                            <input type="checkbox" onchange="ChangeCheck(this);" value="@obj.Id" name="objectid">
                        </td>
                        <td>
                            <ul class="unstyled">
                                <li><a href="@Url.Action("AddObject", "Cabinet", new { id = obj.Id })">@(string.Format("{0} {1}, {2}", obj.Manufacture, obj.Model, obj.Release))</a></li>
                            </ul>
                        </td>
                        <td>
                            <ul class="unstyled">
                                @if (obj.InsurantId == "0")
                                {
                                    <li><a class="add-object-link" href="@Url.Action("AddObject", "Cabinet", new { id = obj.Id })" title="Установить страхователя">
                                        Страхователь отсутствует</a></li> 
                                }
                                else
                                {
                                    <li><a href="@Url.Action("Client", "Clients", new { id = obj.InsurantId })">@obj.FullNameInsurant</a></li>
                                }
                            </ul>
                        </td>
                        <td>
                            <ul>
                                <li><a class="add-object-link" href="@Url.Action("AddObject", "Cabinet", new { id = obj.Id, tab = "tab1" })" title="Добавить продукт страхования">
                                    Продукты отсутствуют</a></li>
                            </ul>
                        </td>
                    </tr>
                    }
                }
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="100%">
                        <div class="table-toolbar">
                            <div class="quant-item pull-left">
                                @Html.DropDownListFor(x => x.PageSize, Model.ListForPageSize, new { @class = "input-mini", onchange = "Filter();" })
                                <span class="help-inline">записей на странице</span>
                            </div>
                            <div class="pagination pagination-right">
                                <ul>
                                    @Html.Paging(Model.PageNumber, Model.PageCount, i => Url.Action("Objects", "Clients", new { page = i, query, status, pagesize }))
                                </ul>
                            </div>
                        </div>
                    </td>
                </tr>
            </tfoot>
        </table>
        <div class="btn-toolbar">
            <button class="btn btn-primary" onclick="location.href='@Url.Action("AddObject", "Cabinet")'">
                Создать объект страхования</button>
            <button class="btn" disabled="disabled" onclick="$('#form1').submit();" state='watch' name="delete">
                Удалить</button>
        </div>
    </div>
</div>
<div class="modal hide " id="call-window">
    <div class="modal-header">
        <button data-dismiss="modal" class="close">
            ×</button>
        <h3>
            Алексей Нежный</h3>
    </div>
    <div class="modal-body">
        <h1>
            8 (926) 616-61-16</h1>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
            incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
            exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        </p>
        <p>
            Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
            fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
            qui officia deserunt mollit anim id est laborum.
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
            incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
            exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Duis aute irure
            dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
            Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
            mollit anim id est laborum.
        </p>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary">
            Позвонить с сайта</button>
        <button data-dismiss="modal" class="btn">
            Закрыть окно</button>
    </div>
</div>
<script type="text/javascript">
    allCheckboxes = $("tbody .col-1 input[type=checkbox]");
</script>
